package gupao.concurrency.threads;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

@Slf4j
public class ThreadDaemonDemo {

    private static void sleepIgnoreExp(long millis){
        try {
            TimeUnit.MILLISECONDS.sleep(millis);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        testRun();
    }

    private static void testRun() throws InterruptedException {
        Runnable r = ()-> {
//            Thread.currentThread().setDaemon(true);
            for( int i = 0; i < 10; i++){
                sleepIgnoreExp(800);
                log.info("{}: {} run, priority: {}", i, Thread.currentThread().getName(), Thread.currentThread().getPriority());
            }
        };

        Thread t = new Thread(r);

        t.start();
    }
}
